//         function show_image(){
//           $.ajax({
//             url:"/img_path",
//             timeout:15000,//超时时间是15秒;
//             success:function(data){
//               //$("#img_path").html(data.split('/')[2]);
//               $(".shoot_img").attr("src",data);//.查找class
//             },
//             error:function(xhr,type,errorThrown){

//             }
//           });
//         }


function show(){
$.ajax({
  url:"/nums",
  timeout:15000,//超时时间是15秒;
  success:function(data){

    console.log(data);
    //data = JSON.parse(data); // 将返回的data字符串转换为数组

    let today = new Date();
    let year = today.getFullYear().toString();//.substr(-2)
    let month = (today.getMonth() + 1).toString().padStart(2, '0');
    let day = today.getDate().toString().padStart(2, '0');
    let img_dir = `../static/images/${year.substr(-2)}${month}${day}/`;
    let tmp_img='../static/images/tea1.png'
    let str,time,currentDate;

    if (data[0] !== 0) {
    str=(data[0] < 10 ? '0' : '') + data[0].toString();//data[0].toString()
    //console.log(img_dir+str+'.png');
    $("#shoot_img1").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;//time.split(".").join("").replace(/(\d{2})(\d{2})/, "$1:$2:")
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path1").html(currentDate);
    }else{
    $("#shoot_img1").attr("src",tmp_img);
    }

    if (data[1] !== 0) {
    str=(data[1] < 10 ? '0' : '') + data[1].toString();
    //console.log(img_dir+str+'.png');
    $("#shoot_img2").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path2").html(currentDate);
    }else{
    $("#shoot_img2").attr("src",tmp_img);
    }

    if (data[2] !== 0) {
    str=(data[2] < 10 ? '0' : '') + data[2].toString();
    //console.log(img_dir+str+'.png');
    $("#shoot_img3").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path3").html(currentDate);
    }else{
    $("#shoot_img3").attr("src",tmp_img);
    }


    if (data[3] !== 0) {
    str=(data[3] < 10 ? '0' : '') + data[3].toString();
    //console.log(img_dir+str+'.png');
    $("#shoot_img4").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path4").html(currentDate);
    }else{
    $("#shoot_img4").attr("src",tmp_img);
    }


    if (data[4] !== 0) {
    str=(data[4] < 10 ? '0' : '') + data[4].toString();
    //console.log(img_dir+str+'.png');
    $("#shoot_img5").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path5").html(currentDate);
    }else{
    $("#shoot_img5").attr("src",tmp_img);
    }


    if (data[5] !== 0) {
    str=(data[5] < 10 ? '0' : '') + data[5].toString();
    //console.log(img_dir+str+'.png');
    $("#shoot_img6").attr("src",img_dir+str+'.png');
    time = `${str.substr(0, 2)}:${str.substr(3, 2)}:${str.substr(5, 2)}`;
    currentDate = `${year}-${month}-${day} ${time}`;
    $("#img_path6").html(currentDate);
    }else{
    $("#shoot_img6").attr("src",tmp_img);
    }

  },
  error:function(xhr,type,errorThrown){

  }
});
}

//        function show_time(){
//                $.ajax({
//                  url:"/time",
//                  timeout:15000,//超时时间是15秒;
//                  success:function(data){
//                    $("#img_path").html(data);
//                  },
//                  error:function(xhr,type,errorThrown){
//
//                  }
//                });
//              }

//show_image();
//show_time();
//setInterval(show_image,3000);//3s
//setInterval(show_time,3000);//3s
show();
setInterval(show,3000);//3s